package com.smartfactory.sail.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smartfactory.sail.entity.User;
import com.smartfactory.sail.mapper.UserMapper;
import com.smartfactory.sail.service.IUserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.smartfactory.sail.utils.PageUtils;
import com.smartfactory.sail.vo.PageParam;
import com.smartfactory.sail.vo.user.ListUserResp;
import com.smartfactory.sail.vo.user.UserInfoResp;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 * 员工管理 服务实现类
 * </p>
 *
 * @author 王巨壁
 * @since 2019-07-25
 */
@Service
public class UserBizzServiceImpl extends ServiceImpl<UserMapper, User> implements IUserService {


    private UserMapper userMapper;

    public UserBizzServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public IPage<ListUserResp> getList(Map<String, Object> queryParam, PageParam pageParam) {

        //分页信息
        Page<ListUserResp> page = new Page<>();
        PageUtils.createPage(page, pageParam);

        QueryWrapper<ListUserResp> query = new QueryWrapper<>();
        query.allEq(queryParam);
        page.setAsc("status");
        return userMapper.getPage(page, query);
    }

    @Override
    public UserInfoResp userInfo(long userId) {
        return userMapper.userInfo(userId);
    }
}
